package doyouknow.group.CnAndZhb.service.impl;

import doyouknow.group.CnAndZhb.dao.fourth.TbcPointDao;
import doyouknow.group.CnAndZhb.entity.TbcPoint;
import doyouknow.group.CnAndZhb.service.TbcPointService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbcPoint)表服务实现类
 *
 * @author makejava
 * @since 2020-12-08 18:20:07
 */
@Service("tbcPointService")
public class TbcPointServiceImpl implements TbcPointService {
    @Resource
    private TbcPointDao tbcPointDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TbcPoint queryById(Integer id) {
        return this.tbcPointDao.queryById(id);
    }

    @Override
    public TbcPoint queryByMac(String mac) {
        return this.tbcPointDao.queryByMac(mac);
    }

    @Override
    public TbcPoint queryByMacPoint(String mac, String pointNum) {return this.tbcPointDao.queryByMacPoint(mac, pointNum);}

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TbcPoint> queryAllByLimit(int offset, int limit) {
        return this.tbcPointDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tbcPoint 实例对象
     * @return 实例对象
     */
    @Override
    public TbcPoint insert(TbcPoint tbcPoint) {
        this.tbcPointDao.insert(tbcPoint);
        return tbcPoint;
    }

    /**
     * 修改数据
     *
     * @param tbcPoint 实例对象
     * @return 实例对象
     */
    @Override
    public TbcPoint update(TbcPoint tbcPoint) {
        this.tbcPointDao.update(tbcPoint);
        return this.queryById(tbcPoint.getId());
    }

    @Override
    public int insertOrUpdateBatch(List<TbcPoint> list){
        return this.tbcPointDao.insertOrUpdateBatch(list);
    };


    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */


    @Override
    public boolean deleteById(Integer id) {
        return this.tbcPointDao.deleteById(id) > 0;
    }

    @Override
    public List <TbcPoint> queryPoints(String gatewayMac) {
        return this.tbcPointDao.queryPoints(gatewayMac);
    }



}